package com.szml.listener;

import com.alibaba.fastjson.JSON;
import com.szml.domain.MsgModel;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @Author limin
 * @date 2025-06-17 16:02
 * @description
 */
@Component
@RocketMQMessageListener(topic = "bootOrderlyTopic",
        consumerGroup = "boot-orderly-conmuser",
        consumeMode = ConsumeMode.ORDERLY,  //顺序消息模式 默认单线程
        maxReconsumeTimes = 5 //消息重试的次数
)
public class BOrderlyMsgListener implements RocketMQListener<MessageExt> {


    @Override
    public void onMessage(MessageExt message) {
        MsgModel msgModel = JSON.parseObject(new String(message.getBody()), MsgModel.class);
        System.out.println(msgModel);

    }
}
